#ifndef WHILE_DO_SCHEDULER_H
#define WHILE_DO_SCHEDULER_H

#include "abstract_scheduler.h"
#include "global.h"

namespace scheduler
{
/**
 * @brief:  循环式任务，需要设置一个判断条件和一个循环执行体，当判断条件执行SUCCESS后，开始运行执行体，如果判断条件返回FAILURE，则不运行执行体，结束所有任务
 *
 * @author: sherlock_lht
 */
class WhileDoScheduler: public AbstractScheduler
{
public:
    explicit WhileDoScheduler(const std::string &name);
    ~WhileDoScheduler() override;

    /**
     * @brief:  设置循环条件判断
     * @author: sherlock_lht
     */
    bool setWhileConditionTask(const task::AbstractTaskConstPtr &task);
    bool setWhileConditionScheduler(const AbstractSchedulerConstPtr &scheduler);

    /**
     * @brief:  设置循环条件判断
     * @author: sherlock_lht
     */
    bool setExecuteTask(const task::AbstractTaskConstPtr &task);
    bool setExecuteScheduler(const AbstractSchedulerConstPtr &scheduler);

    /**
     * @brief:  设置执行体退出条件，即execute task一次执行后，如果执行结果==status，则退出循环，都则继续
     * @note:   running状态无效
     * @author: sherlock_lht
     */
    void setEndCondition(task::TaskStatus status);

    [[deprecated("while do else scheduler cannot append task")]] bool appendTask(const task::AbstractTaskConstPtr &task) override;

    [[deprecated("while do else scheduler cannot append scheduler")]] bool appendScheduler(const AbstractSchedulerConstPtr &scheduler) override;

    [[deprecated("while do else scheduler cannot set task")]] bool setTask(const task::AbstractTaskConstPtr &task) override;

    [[deprecated("while do else scheduler cannot set task")]] bool setScheduler(const AbstractSchedulerConstPtr &scheduler) override;
};

}

#endif //WHILE_DO_SCHEDULER_H
